using UnityEngine;
using System.Collections;

public class DynamicCamera : MonoBehaviour 
{
	
	public Transform target;
	public Transform target1;
	public Transform target2;
	public Transform target3;
	
	public float relativeHeight = 2.0f;
	
	public float zDistance = 5.0f;
	
	public float dampSpeed = 2;
	
	
	int selectedCharacter = 0;
	string characterName;
	
	GameObject[] chrChange = new GameObject[3];
	
	
	// Use this for initialization
	void Start () {
		
		//target.tag = "joana";
			
	}
	
	// Update is called once per frame
	void Update () 
	{
		
		if(Input.GetKeyDown(KeyCode.Q))
	   	{
	      if (selectedCharacter < 1)
	          selectedCharacter++;
	      else
	          selectedCharacter = 0;
  
	      for (int i = 1; i < 2; ++i)
	      {
	         if(i != selectedCharacter)
	    	 {
	    		characterName = "Camera" + i;
	    		GameObject.Find(characterName).renderer.enabled = false;
				
	    	 }
				
	    	 else
	    	 {
	    		characterName = "Camera" + selectedCharacter;
	    		GameObject.Find(characterName).renderer.enabled = true;			
				
	    	 }
				
	      }
	   	}		
		
		if(target.tag == "joana")
		{
		
			Vector3 newPos = target.position + new Vector3(0,relativeHeight, -zDistance);
			
			transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * dampSpeed);
			
		}
	}
}
